The Create-A-Card application lets you create a custom birthday card. When you enter the name and age of a recipient and click submit, the application returns a page with a birthday greeting. The application maintains a global variable namesArray that contains the names of all card recipients. When a user clicks the 'Show all recipients' button, the application returns a page listing all of the recipients across all sessions.
The Create-A-Card application uses a WORepetition, which is a dynamic element that displays itself as a list in an HTML page. A WORepetition has two attributes: a list, which is an NSArray object that contains a collection of items, and an item, which is an NSDictionary that represents an item in the list. An NSDictionary is a collection of key-value pairs. Each NSDictionary object in the namesArray includes the key "aName" whose corresponding value is the name of a recipient.
This WORepetition is declared in the declarations file Recipients.wod. The second declaration sets the value of anItem to be aName, which corresponds to the name of a recipient:
NAMEGROUP:WORepetition { list = WOApp.namesArray; item = anItem; }; NAMEGROUP.A_NAME:WOString { value = anItem.aName; };
When a user clicks the 'Show all recipients' button to navigate to the Recipients page, the namesArray is iterated, and the name of each recipient is displayed-- or, to put it differently, the value associated with the key aName in each anItem NSDictionary is displayed.